// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Vuex from 'vuex'
import './permission.js'// 权限
import store from './store'
import App from './App'
import router from './router'
import {route1, route2, route3} from '@/router/index.js';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import { Button, Select,Input} from 'element-ui';
import $ from 'jquery'
import {post,fetch,patch,put,cut} from '@/common/http'
import moment from 'moment/moment'
import * as urls from '../config/env'
// import htmlToPdf from '@/components/utils/htmlToPdf'
// Vue.use(htmlToPdf);
// 引入vue-amap
import AMap from 'vue-amap';

Vue.use(AMap);
//滑块验证
import SlideVerify from 'vue-monoplasty-slide-verify';
Vue.use(SlideVerify);

//引入走马灯
 import 'swiper/css/swiper.css'
Vue.filter('moment', function (value, formatString) {
  formatString = formatString || 'YYYY-MM-DD HH:mm:ss';
  // return moment(value).format(formatString); // value可以是普通日期 20170723
  return moment.unix(value).format(formatString); // 这是时间戳转时间
});
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts
//定义全局变量
Vue.prototype.$post=post;
Vue.prototype.$fetch=fetch;
Vue.prototype.$patch=patch;
Vue.prototype.$put=put;
Vue.prototype.$cut=cut;
Vue.component(Button.name, Button);
Vue.component(Select.name, Select);
Vue.component(Input.name, Input);

Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(Vuex);
Vue.prototype.$admin = store
// Vue.prototype.$http = http
//Vue.prototype.$axios = axios
//把 myAxios  ==》 赋给vue的原型
//myAxios.defaults.crossDomain = true;
//myAxios.defaults.withCredentials = true
// Vue.prototype.$axios = myAxios
// // 初始化vue-amap
let clientType = localStorage.getItem('clientType')
if(clientType) {
  store.commit('permission/SET_Client', clientType)
  if (clientType == 1) {
    router.addRoutes(route1);
 //   router.push({name:'HomePage'})
  } else if (clientType == 2) {
    router.addRoutes(route2);
   // router.push({name:'CustomerHomePage'})
  }else if (clientType == 3) {
    router.addRoutes(route3);
  //  router.push({name:'MageHomePage'})
    // this.$router.addRoutes("MageHomePageHomePage");
  }
}

AMap.initAMapApiLoader({
  // 高德的key
  key: '7ef26c7cd428033ad4d2a3748b917fc5',
  // 插件集合 （插件按需引入）
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor']
});
// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key]
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
